﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
using Tong.Fy;
public partial class Use_Use_Search : System.Web.UI.Page
{

    /// <summary>
    /// 字段的值 
    /// </summary>
    string BaValue;
    /// <summary>
    /// 
    /// 字段
    /// </summary>
    string[] BaItems;
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;

    /// <summary>
    /// 分页类 調用分頁函數
    /// </summary>
    public FenYe FY = new FenYe();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.ToString() != "")
        {
            BaItems = Request.QueryString.AllKeys;
            //指定字段接收 不会出现乱码   Request.QueryString[Request.QueryString.GetKey(i)]
            for (int i = 0; i < BaItems.Length; i++)
            {
                BaValue = Request.QueryString[Request.QueryString.GetKey(0)];//得到URL值
            }

            MyDt = TextData.SqlataSet("select * from [use] where " + BaItems[0] + " like '%" + BaValue + "%' ").Tables[0];

            if (MyDt.Rows.Count > 0)//如果不只一条记录
            {
                Grid_Use_Search.DataSource = FY.Fy("select * from [use] where " + BaItems[0] + " like '%" + BaValue + "%' ", 4000);//得到数据的东东
                Grid_Use_Search.DataBind();
                Div.InnerHtml = FY.GetHTML;
            }
            else
            {
                Grid_Use_Search.ShowHeader = false;//不显
                tt.Text = "没有搜索到 " + BaValue + " 相关的数据";
            }
        }
        
    }
    /// <summary>
    /// 还原密码事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void rePwd(object sender, EventArgs e)
    {//((LinkButton)sender)得到linkbutton对象所有的属性,与sender对象一样 就可以使用了哦

        int id = int.Parse(((LinkButton)sender).CommandArgument.ToString());//设定id 
        string pwd = "123456789";//密码 要还原的密码
        pwd = TextData.SHA1Sign(pwd);
        TextData.SqlDataSave("update [Use] Set pwd = '" + pwd + "' where Use_id =  " + id);
        tt.Text = "已成功还原 用户   " + TextData.SqlataSet("select * from [use] where Use_id = " + id).Tables[0].Rows[0]["uid"].ToString() + "   的密码 密码为 123456789 ";

    }


}
